package com.cyc.controller;

import com.alibaba.fastjson.JSON;
import com.cyc.service.SendSms;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

@RequestMapping("send")
@Controller
public class SendSmsController {
    @Autowired
    SendSms sendSms;

    @RequestMapping("code")
    @ResponseBody
    public String code(String phone){
        Map<String, Object> map=new HashMap<>();
         String code = sendSms.send(phone);
         if (!code.equals("")){
             map.put("msg","验证码发送成功");
             map.put("code",code);
             return JSON.toJSONString(map);
         }
         map.put("code","0");
        map.put("msg","验证码发送失败");
        return JSON.toJSONString(map);
    }

}
